document.addEventListener('DOMContentLoaded', function() {
    // 处理菜单展开/折叠
    const menuItems = document.querySelectorAll('.has-submenu');

    menuItems.forEach(item => {
        const menuLink = item.querySelector('.menu-link');

        menuLink.addEventListener('click', function(e) {
            e.preventDefault();

            // 关闭其他打开的菜单
            menuItems.forEach(otherItem => {
                if (otherItem !== item && otherItem.classList.contains('active')) {
                    otherItem.classList.remove('active');
                }
            });

            // 切换当前菜单状态
            item.classList.toggle('active');
        });
    });

    // 点击空白处关闭菜单
    document.addEventListener('click', function(e) {
        if (!e.target.closest('.has-submenu')) {
            menuItems.forEach(item => {
                item.classList.remove('active');
            });
        }
    });

    // 处理表格行悬停效果
    const tableRows = document.querySelectorAll('.data-table tbody tr');

    tableRows.forEach(row => {
        row.addEventListener('mouseenter', function() {
            this.style.backgroundColor = '#f9f9f9';
        });

        row.addEventListener('mouseleave', function() {
            this.style.backgroundColor = '';
        });
    });
});